import dbus
from PyQt5.QtWidgets import QSystemTrayIcon
from .platform_detect import LinuxEnv

def show_notification(title, message, tray=None):
    """跨平台通知显示"""
    try:
        # DBus通知（Deepin/Ubu
        bus = dbus.SessionBus()
        notify_interface = dbus.Interface(
            bus.get_object('org.freedesktop.Notifications', '/org/freedesktop/Notifications'),
            'org.freedesktop.Notifications'
        )
        notify_interface.Notify(
            "deskmanager", 0, "",
            title, message, [], {"urgency": 1}, 5000
        )
    except:
        # 备用Qt通知（KDE等）
        if tray and isinstance(tray, QSystemTrayIcon):
            tray.showMessage(title, message, QSystemTrayIcon.Information, 5000)